<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "contract".
 *
 * @property int $id
 * @property int $pid
 * @property string $code
 * @property int $uid
 * @property int $sign_at
 * @property int $start_at
 * @property int $over_at
 * @property int $month
 * @property int $total_fee
 * @property string $remark
 * @property string $audit_msg
 * @property int $status 状态:1=待审核;2=审核驳回;3=审核通过;100=已完结
 * @property int $is_del
 * @property int $aid
 * @property int $updated_at
 * @property int $created_at
 */
class Contract extends BaseModel
{

    const SCENARIO_ADD     = 'add';
    const SCENARIO_EDIT    = 'edit';
    const SCENARIO_REMOVE  = 'remove';
    const SCENARIO_DISABLE = 'disable';
    const SCENARIO_ENABLE  = 'enable';
    const SCENARIO_CHANGE_PASSWORD  = 'change_password';
    const SCENARIO_SEEK_PASSWORD  = 'seek_password';
    const SCENARIO_EDIT_PASSWORD  = 'edit_password';
    const SCENARIO_RESET_PASSWORD  = 'reset_password';

    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'contract';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['pid', 'uid', 'sign_at', 'start_at', 'over_at', 'month', 'total_fee', 'status', 'is_del', 'updated_aid', 'updated_at', 'created_aid', 'created_at'], 'integer'],
            [['code', 'uid'], 'required'],
            [['code'], 'string', 'max' => 64],
            [['remark', 'audit_msg'], 'string', 'max' => 100],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'pid' => 'Pid',
            'code' => 'Code',
            'uid' => 'Uid',
            'sign_at' => 'Sign At',
            'start_at' => 'Start At',
            'over_at' => 'Over At',
            'month' => 'Month',
            'total_fee' => 'Total Fee',
            'remark' => 'Remark',
            'audit_msg' => 'Audit Msg',
            'status' => 'Status',
            'is_del' => 'Is Del',
            'updated_aid' => 'Updated Aid',
            'updated_at' => 'Updated At',
            'created_aid' => 'Created Aid',
            'created_at' => 'Created At',
        ];
    }

    public function scenarios()
    {
        $scenarios = parent::scenarios();
        $scenarios[self::SCENARIO_ADD] = ['pid', 'uid', 'code', 'remark', 'sign_at', 'start_at', 'over_at', 'month', 'total_fee', 'remark', 'status'];
        return $scenarios;
    }
}
